import request from "@/utils/request";
import {
  Captcha,
  LoginFormData,
  LoginResponseData,
} from "@/types/api/system/login";
import { AxiosPromise } from "axios";

/**
 * 登录接口
 * @param data 登录所需数据
 * @returns
 */
export const login = (data: LoginFormData): AxiosPromise<LoginResponseData> => {
  return request({
    url: "/api/login",
    method: "post",
    data: data,
    headers: {
      Authorization: "Basic bWFsbC1hZG1pbjoxMjM0NTY=", // 客户端信息Base64明文：mall-admin-web:123456
    },
  });
};
/**
 * 注册用户
 * @returns
 */
export const regist = (data: any) => {
  return request({
    url: "/api/regist",
    method: "post",
    data: data,
  });
};

/**
 * 获取图片验证码
 */
export function getCaptcha(): AxiosPromise<Captcha> {
  return request({
    url: "/prod-api/captcha?t=" + new Date().getTime().toString(),
    method: "get",
  });
}
